
				<div class="box span12">
					<div class="box-header" data-original-title>
						<h2><i class="halflings-icon white edit"></i><span class="break"></span>角色添加</h2>
						<div class="box-icon">
							<a href="#" class="btn-setting"><i class="halflings-icon white wrench"></i></a>
							<a href="#" class="btn-minimize"><i class="halflings-icon white chevron-up"></i></a>
							<a href="#" class="btn-close"><i class="halflings-icon white remove"></i></a>
						</div>
					</div>
					<div class="box-content">
						<form class="form-horizontal" method="post" action="index.php?c=role&a=add&admin=1">
						  <fieldset>
							<div class="control-group">
							  <label class="control-label" for="typeahead">角色名称</label>
							  <div class="controls">
								<input type="text" name="name" class="span6 typeahead username" id="typeahead"  data-provide="typeahead" data-items="4">
							  </div>
							</div>
                            <div class="control-group">
                                <label class="control-label">是否启用</label>
                                <div class="controls">
                                  <label class="radio">
                                    <input type="radio" name="status" id="optionsRadios1" value="1" checked="">
                                    是
                                  </label>
                                  <div style="clear:both"></div>
                                  <label class="radio">
                                    <input type="radio" name="status" id="optionsRadios2" value="0">
                                    否
                                  </label>
                                </div>
                            </div>
                              <div class="control-group" style="margin-left:150px ;">
                                  <button type="button" file="0" class="btn btn-primary allcheck">全选/反选</button>
                              </div>
                              <?php foreach($parent as $v){?>
                            <div class="control-group" style="margin-left:45px ;">
                                <label class="control-label checkbox1"><span class="fa-che"><input name="power[]" file="0" type="checkbox" value="<?php echo $v['id'];?>" id="inlineCheckbox0"><?php echo $v['name'];?></span></label>
                                <div class="controls">
                                <?php foreach($child as $vc){
                                        if($v['id']==$vc['pid']){
                                ?>
                                  <label class="checkbox inline">
                                    <div class="checker" id="uniform-inlineCheckbox1"><span class=""><input name="power[]" type="checkbox" value="<?php echo $vc['id']?>" id="inlineCheckbox1"></span></div> <?php echo $vc['name']?>
                                  </label>
                                  <?php }
                                  } ?>
                                </div>
                            </div>
                            <?php }?>
							<div class="form-actions">
							  <button type="submit" class="btn btn-primary">提交</button>
							  <button type="reset" class="btn">清空</button>
							</div>
						  </fieldset>
						</form>

					</div>
				</div><!--/span-->
                <script src="resources/admin/js/jquery-1.9.1.min.js"></script>
                <script  type="text/javascript">
                $(function(){
                    //全选反选
                    $('.allcheck').click(function(){
                            // alert($(':checkbox').length);
                        var y=$(this).attr('file');
                        if(y==0){
                            $(this).attr('file',1);
                            $('.checkbox1 input').attr('file',1);
                            $('.checkbox2 input').attr('file',1);
                            $('.checkbox3 input').attr('file',1);
                            $(':checkbox').attr('checked',true);
                            $('.checker span').addClass('checked');
                        }else{
                            $(this).attr('file',0);
                            $('.checkbox1 input').attr('file',0);
                            $('.checkbox2 input').attr('file',0);
                            $('.checkbox3 input').attr('file',0);
                            $(':checkbox').attr('checked',false);
                            $('.checker span').removeClass('checked');
                        }
                    })
                    $('.checkbox1 input').click(function(){
                        var y=$(this).attr('file');
                        var cheinp=$(this);
                        che(y,cheinp);
                    })
                    $('.checkbox2 input').click(function(){
                        var y=$(this).attr('file');
                        var cheinp=$(this);
                        che(y,cheinp);
                    })
                    $('.checkbox3 input').click(function(){
                        var y=$(this).attr('file');
                        var cheinp=$(this);
                        che(y,cheinp);
                    })
                    $('.controls :checkbox').click(function(){
                       var len=$(this).parents('div.controls').find(':checkbox:checked').length;
                       if(len>0){
                        $(this).parents('div.controls').parent().find('.control-label .fa-che div span').addClass('checked');
                        $(this).parents('div.controls').parent().find('.control-label .fa-che :checkbox').attr('checked',true);
                        $(this).parents('div.controls').parent().find('.control-label .fa-che div span input').attr('file',1);
                       }else{
                        $(this).parents('div.controls').parent().find('.control-label .fa-che div span').removeClass('checked');
                        $(this).parents('div.controls').parent().find('.control-label .fa-che :checkbox').attr('checked',false);
                        $(this).parents('div.controls').parent().find('.control-label .fa-che div span input').attr('file',0);
                       }
                     })
                    //父级勾选框事件
                    function che(y,cheinp){
                      if(y==0){
                            cheinp.attr('file',1);
                            cheinp.parent().parent().parent().parent().next().find(':checkbox').prop('checked',true);
                            cheinp.parent().parent().parent().parent().next().find('span').addClass('checked');
                        }else{
                            cheinp.attr('file',0);
                            cheinp.parent().parent().parent().parent().next().find(':checkbox').prop('checked',false);
                            cheinp.parent().parent().parent().parent().next().find('span').removeClass('checked');
                        }

                    }
                })
                </script>

